package com.company.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.stereotype.Component;
import org.springframework.util.StringValueResolver;

@Component
public class Red implements ApplicationContextAware, BeanNameAware, EmbeddedValueResolverAware {
    private ApplicationContextAware applicationContextAware;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("传入的ioc=" + applicationContext);
        this.applicationContextAware = applicationContextAware;
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("name=" + s);
    }

    @Override
    //解析器
    public void setEmbeddedValueResolver(StringValueResolver stringValueResolver) {
        String stringValue = stringValueResolver.resolveStringValue("你好，${os.name} 我是#{20*18}");
        System.out.println("解析后的值=" + stringValue);
    }
}
